package logic

import (
	"game/src/common"
	"time"
)

type RoleData struct {
	Id           int
	Name         string
	CreateTime   time.Time
	AllianceName string
}

type Role struct {
	Id        int
	Data      *RoleData
	LoginTime time.Time

	Alliance   *AllianceData
	Connection common.IConnection
}

func NewRoleData(name string) *RoleData {
	return &RoleData{
		Name:       name,
		CreateTime: time.Now(),
	}
}

func NewRole(data *RoleData) *Role {
	return &Role{
		Id:        data.Id,
		Data:      data,
		LoginTime: time.Now(),
	}
}
func (r Role) OutAlliance() {
	r.Data.AllianceName = ""
	r.Alliance = nil
}
